package com.mine.androidlearn.tempnet;

import android.content.Context;
import android.util.Log;

import com.mine.androidlearn.api.bean.WeatherInfoBean;
import com.mine.androidlearn.common.base.BasePresenter;

import rx.Subscriber;
import rx.functions.Action1;

public class NetPresenter extends BasePresenter<INetContract.view> implements INetContract.presenter {

    public NetPresenter(Context context) {
        super(context);
    }

    @SuppressWarnings("unchecked")
    @Override
    public void loadWeatherInfo(String key, String city) {
        getView().showLoading();
        addSubscription(
                mApi.loadWeatherInfo(key, city)
                        .subscribe(newSubscriber(new Action1<WeatherInfoBean>() {
                            @Override
                            public void call(WeatherInfoBean weatherInfoBean) {
                                getView().hideLoading();
                                getView().loadWeatherInfoSuccess(weatherInfoBean);
                            }
                        }, getView(), false)));

    }
}
